{% extends "stg_inv.html" %}
{% block title %}Batch Inventory Summary{% endblock %}
{% block body %}
<p><a href="/">&larr;Hachoir</a></p>
<p><a href="{% url 'stg_index' %}">&larr;Staging</a></p>
<h1>File Inventory</h1>

<h3>Filters</h3>
<ul>
    <li>State: {{ state_abbr }} {% if state_abbr != "all" %}<a href="{% url 'djhcup_staging.views.obj_inventory' obj_type='File' state_abbr="all" year=year %}">(drop filter&rarr;)</a>{% endif %}</li>
    <li>Year: {{ year }} {% if year != "all" %}<a href="{% url 'djhcup_staging.views.obj_inventory' obj_type='File' state_abbr=state_abbr year="all" %}">(drop filter&rarr;)</a>{% endif %}</li>
</ul>

<h2>Content Files</h2>
{% if content|length > 0 %}
    {% regroup content by state.abbreviation as st_grouped %}
    <ul>
        {% for st in st_grouped %}
        <li><a href="{% url 'djhcup_staging.views.obj_inventory' obj_type='File' state_abbr=st.grouper year=year %}">{{ st.grouper }}</a>
        <ul>
            {% regroup st.list by year as yr_grouped %}
            {% for yr in yr_grouped %}
                <li><a href="{% url 'djhcup_staging.views.obj_inventory' obj_type='File' state_abbr=state_abbr year=yr.grouper %}">{{ yr.grouper }}</a>
                <ul>{% for f in yr.list %}
                        <!-- Details/display for each File object -->
                        {% with f.file_type as ft %}
                            <li><a href="{{ f.get_absolute_url }}">{{ f.filename }} ({{ ft.source.hr_descriptor }} {{ ft.content_type }})</a></li>
                        {% endwith %}
                    {% endfor %}
                </ul>
                </li>
            {% endfor %}
        </ul>
        </li>
        {% endfor %}
    </ul>
{% else %}
<p>No content files.</p>
{% endif %}


<h2>Loading Files</h2>
{% regroup loadfiles by state.abbreviation as st_grouped %}
<ul>
    {% for st in st_grouped %}
    <li><a href="{% url 'djhcup_staging.views.obj_inventory' obj_type='File' state_abbr=st.grouper year=year %}">{{ st.grouper }}</a>
    <ul>
        {% regroup st.list by year as yr_grouped %}
        {% for yr in yr_grouped %}
            <li><a href="{% url 'djhcup_staging.views.obj_inventory' obj_type='File' state_abbr=state_abbr year=yr.grouper %}">{{ yr.grouper }}</a>
            <ul>{% for f in yr.list %}
                    <!-- Details/display for each File object -->
                    {% with f.file_type as ft %}
                        <li><a href="{{ f.get_absolute_url }}">{{ f.filename }} ({{ ft.source.hr_descriptor }} {{ ft.content_type }})</a></li>
                    {% endwith %}
                {% endfor %}
            </ul>
            </li>
        {% endfor %}
    </ul>
    </li>
    {% endfor %}
</ul>


{% endblock %}
